cmake_minimum_required(VERSION 3.15)

if(NOT CMAKE_BUILD_TYPE)
    set(CMAKE_BUILD_TYPE Release)
endif()
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_AUTOMOC ON)

project(manageBycmake LANGUAGES CXX)

# configure阶段设置 Qt6_DIR 缓存变量 查找Qt6Config.cmake
# cmake -B build -DQt6_DIRP=...
find_package(Qt6 COMPONENTS Core REQUIRED)

file(GLOB_RECURSE sources CONFIGURE_DEPENDS "./src/*.cpp" "./include/*/*.h")
message("$$ ${sources}")

# exe
add_executable(main main.cpp ${sources})
target_include_directories(main PRIVATE include/myobject)
target_link_libraries(main PRIVATE Qt6::Core)

# 伪目标 
add_custom_target(  run 
                    COMMAND $<TARGET_FILE:main>
                    COMMENT "运行main"
                    DEPENDS main)

add_custom_target(  test
                    COMMAND ${CMAKE_COMMAND} -E echo "" 
                    COMMENT "测试生成器表达式")

# 自定义目标和自定义命令 COMMAND 不要加引号
add_custom_command( TARGET test
                    COMMAND ${CMAKE_COMMAND} -E echo $<TARGET_FILE:main> 
                    COMMENT "拷贝文件")

# 生成器表达式(发生在构建时)
add_custom_command( TARGET test
                    COMMAND echo $<CXX_COMPILER_ID> $<CXX_COMPILER_ID:GNU>)

set(a 1;2;3;a;b;c)
add_custom_command( TARGET test
                    COMMAND echo ${a})
                    